home *** CD-ROM | disk | FTP | other *** search
- /* ------------------------------------------------------------------------------
-
- FILENAME
- CollectionLibrary.c
-
- DESCRIPTION
- Handy printing collection functions.
-
- COPYRIGHT
- © Apple Computer, Inc. 1990-1991
- All rights reserved.
-
- -------------------------------------------------------------------------------- */
-
- #include <PrintingManager.h>
- #include <PrintingLibraries.h>
- #include <Errors.h>
-
-
- #define kCategoryMask 0x0000FFFF
-
-
-
- /****************************************************************************************
-
- SetCollectionItemCategory
-
- function :
- Assigns a tag/ID pair to a category in the given collection.
- parameters :
- the collection, the tag, the ID, and the category
-
- ****************************************************************************************/
- OSErr SetCollectionItemCategory ( Collection theCollection,
- CollectionTag tag,
- long tagID,
- gxCollectionCategory theCategory)
- {
- OSErr anErr;
-
-
- // Set the item's attributes to be the provided category, ORed with the existing bits.
-
- anErr = SetCollectionItemInfo( theCollection,
- tag,
- tagID,
- kCategoryMask,
- (long) theCategory);
-
- return (anErr);
- }
- /****************************************************************************************
-
- GetCollectionItemCategory
-
- function :
- Returns the category assigned to the tag/ID pair
- in the given collection.
- parameters :
-
- ****************************************************************************************/
- OSErr GetCollectionItemCategory( Collection theCollection,
- CollectionTag tag,
- long tagID,
- gxCollectionCategory *theCategory)
- {
- OSErr anErr;
- long attributes;
-
-
- // Get the item's attributes in the provided category. Then get the category bits
-
- anErr = GetCollectionItemInfo( theCollection,
- tag,
- tagID,
- dontWantIndex,
- dontWantSize,
- &attributes);
-
- *theCategory = attributes & kCategoryMask;
-
- return (anErr);
- }
-
-
- /****************************************************************************************
-
- RemoveCollectionCategory
-
- function :
- Removes a category from the given collection
- parameters :
-
- ****************************************************************************************/
- OSErr RemoveCollectionCategory( Collection theCollection,
- gxCollectionCategory theCategory)
- {
-
- // Yank all the items which have those bits set.
-
- PurgeCollection(theCollection, theCategory, theCategory);
-
- return (noErr);
- }
-
- /****************************************************************************************
-
- GetCollectionItemLock
-
- function :
- Returns true if the item is locked
- parameters :
- the collection, tag, and ID
-
- returns:
- OSErrs
- *isLocked contains the lock state
-
- ****************************************************************************************/
- OSErr GetCollectionItemLock( Collection theCollection,
- CollectionTag tag,
- long tagID,
- Boolean *isLocked)
- {
- OSErr anErr;
- long attributes;
-
- // Get the attributes of the item in question
-
- anErr = GetCollectionItemInfo( theCollection,
- tag,
- tagID,
- nil, // don't want the index
- nil, // don't want the size
- &attributes);
-
-
- // Then determine if "locked" is one of the attributes.
-
- *isLocked = ((attributes & collectionLockMask) == collectionLockMask);
-
- return (anErr);
- }
- /****************************************************************************************
-
- SetCollectionItemLock
-
- function :
- Locks the given item
- parameters :
-
- ****************************************************************************************/
- OSErr SetCollectionItemLock( Collection theCollection,
- CollectionTag tag,
- long tagID,
- Boolean lockIt)
- {
- OSErr anErr;
- long lockState;
-
-
- // Set the bit according to lockIt.
-
- if (lockIt)
- lockState = collectionLockMask;
- else
- lockState = 0;
-
- anErr = SetCollectionItemInfo( theCollection,
- tag,
- tagID,
- collectionLockMask,
- lockState);
-
- return (anErr);
- }
-
-
- /****************************************************************************************
-
- AddJobItem
-
- function :
- Adds an item to a job collection.
- parameters :
- the collection, the tag, the ID, and the category
-
- ****************************************************************************************/
- OSErr AddJobItem (gxJob aJob, CollectionTag tag, long id, long itemSize, void *itemData)
- {
- if (!aJob) return paramErr;
- return AddCollectionItem(GXGetJobCollection(aJob), tag, id, itemSize, itemData);
- }
-
-
- /****************************************************************************************
-
- AddFormatItem
-
- function :
- Adds an item to a format collection.
- parameters :
- the collection, the tag, the ID, and the category
-
- ****************************************************************************************/
- OSErr AddFormatItem (gxFormat aFormat, CollectionTag tag, long id, long itemSize, void *itemData)
- {
- if (!aFormat) return paramErr;
- return AddCollectionItem(GXGetFormatCollection(aFormat), tag, id, itemSize, itemData);
- }
-
-
-
- /****************************************************************************************
-
- AddVolatileJobItem
-
- function :
- Adds a purgeable item to a job collection.
- When called by driver, will auotmatically
- set the correct bits to make the item purgeable for that driver.
- parameters :
- the collection, the tag, the ID, and the category
-
- ****************************************************************************************/
- OSErr AddVolatileJobItem (gxJob aJob, CollectionTag tag, long id, long itemSize, void *itemData)
- {
- OSErr anErr;
- Collection jobCollection;
-
- if (!aJob) return paramErr;
- jobCollection = GXGetJobCollection(aJob);
-
- anErr = AddCollectionItem(jobCollection, tag, id, itemSize, itemData);
-
- if (!anErr) {
- gxCollectionCategory category = (GXGetJobPrinter(aJob) == GXGetJobOutputPrinter(aJob))
- ? gxVolatileOutputDriverCategory
- : gxVolatileFormattingDriverCategory;
-
- (void) SetCollectionItemCategory(jobCollection, tag, id, category);
- }
- return anErr;
- }
-
-
- /****************************************************************************************
-
- AddVolatileFormatItem
-
- function :
- Adds a purgeable item to a format collection.
- When called by driver, will auotmatically
- set the correct bits to make the item purgeable for that driver.
- parameters :
- the collection, the tag, the ID, and the category
-
- ****************************************************************************************/
- OSErr AddVolatileFormatItem (gxFormat aFormat, CollectionTag tag, long id, long itemSize, void *itemData)
- {
- OSErr anErr;
- Collection formatCollection;
-
- if (!aFormat) return paramErr;
- formatCollection = GXGetFormatCollection(aFormat);
-
- anErr = AddCollectionItem(formatCollection, tag, id, itemSize, itemData);
-
- if (!anErr) {
- gxJob aJob = GXGetFormatJob(aFormat);
- gxCollectionCategory category = (GXGetJobPrinter(aJob) == GXGetJobOutputPrinter(aJob))
- ? gxVolatileOutputDriverCategory
- :gxVolatileFormattingDriverCategory;
-
- (void) SetCollectionItemCategory(formatCollection, tag, id, category);
- }
- return anErr;
- }
-